package com.hamizhong.iflowers.web.action.admin.orders;

import java.util.List;

import com.hamizhong.iflowers.service.ICityService;
import com.hamizhong.iflowers.service.IGoodsService;
import com.hamizhong.iflowers.service.IOrdersService;
import com.hamizhong.iflowers.service.IProvinceService;
import com.hamizhong.iflowers.utils.MyColumnIndicator;
import com.hamizhong.iflowers.utils.MyTools;
import com.hamizhong.iflowers.web.base.MyBaseAction;
import com.hamizhong.iflowers.web.dto.IOPResultDto;
import com.hamizhong.iflowers.web.vo.IObjectVO;
import com.hamizhong.iflowers.web.vo.OrdersVO;

public class OrderDetailAction extends MyBaseAction {
	private IOrdersService iOrdersService = null;
	private IProvinceService iProvinceService = null;
	private ICityService iCityService = null;
	private IGoodsService iGoodsService = null;
	public IOrdersService getiOrdersService() {
		return iOrdersService;
	}
	public void setiOrdersService(IOrdersService iOrdersService) {
		this.iOrdersService = iOrdersService;
	}
	public IProvinceService getiProvinceService() {
		return iProvinceService;
	}
	public void setiProvinceService(IProvinceService iProvinceService) {
		this.iProvinceService = iProvinceService;
	}
	public ICityService getiCityService() {
		return iCityService;
	}
	public void setiCityService(ICityService iCityService) {
		this.iCityService = iCityService;
	}
	public IGoodsService getiGoodsService() {
		return iGoodsService;
	}
	public void setiGoodsService(IGoodsService iGoodsService) {
		this.iGoodsService = iGoodsService;
	}
	
	@Override
	protected String doRequest() {
		logger.info("----------------- Hello OrderDetailAction -----------------");
		String orderId = getRQ().getParameter("orderId");
		IOPResultDto<IObjectVO> dto = iOrdersService.findByOrderId(Integer.valueOf(orderId));
		if(dto.isSuccess()) {
			List<OrdersVO> ordersVOList = dto.getFirstResult().getOrdersVOList();
			OrdersVO ordersVO = ordersVOList.get(0);
		/*	if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_A) {
				ordersVO.setOrderStateStr("新订单");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_B) {
				ordersVO.setOrderStateStr("已发货");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_C) {
				ordersVO.setOrderStateStr("已签收");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_D) {
				ordersVO.setOrderStateStr("已完成");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_BACK_A) {
				ordersVO.setOrderStateStr("用户退订中");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_BACK_C) {
				ordersVO.setOrderStateStr("用户退订完成");
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_BACK_B) {
				ordersVO.setOrderStateStr("管理员退订完成");
			}*/
			ordersVO.setOrderStateStr(MyColumnIndicator.O_ST_DESC_MAP.get(ordersVO.getOrderState()));
			ordersVO.setCreateDateStr(MyTools.formatDttm2YYYY_MM_DD_HH_MM_SS(ordersVO.getCreateDate()));
			ordersVO.setDoneDateStr(MyTools.formatDttm2YYYY_MM_DD_HH_MM_SS(ordersVO.getDoneDate()));
			getRQ().setAttribute("ordersVO", ordersVO);
			return SUCCESS;
		}else {
			return ERROR;
		}
	}

}
